using System;
using SKBKontur.Logging.Model;

namespace SKBKontur.Logging
{
    public class ConsoleLevelDispatchingLogEventWriterConfigurator : ILevelDispatchingLogEventWriterConfigurator
    {
        private readonly string delimeter;

        public ConsoleLevelDispatchingLogEventWriterConfigurator(string delimeter)
        {
            this.delimeter = delimeter;
        }

        public ILogEventWriter this[LogEventLevel level]
        {
            get
            {
                switch(level)
                {
                    case LogEventLevel.Error:
                    case LogEventLevel.Fatal:
                        return new JsonLogEventWriter(delimeter, Console.OpenStandardError());
                    default:
                        return new JsonLogEventWriter(delimeter, Console.OpenStandardOutput());
                }
            }
        }
    }
}